from google.appengine.ext import db
from google.appengine.ext import search
from google.appengine.api import memcache

from models import Questions

"""Defines several utility functions which are necessary for day to day actions,
but can not be included anywhere else
"""

def search(keyword):
    "Searches across Question/Answers"
    initial_results = Questions.all().search(keyword)
    return initial_results

def recent_help_topic(count=10):
    "Returns the help pages created recently"
    return Questions.all().order('-created').fetch(count)

def featured_questions(count=10):
    "Returns the featured questions"
    return Questions.all().filter('featured =', True)